import ValAjax from '@/utils/ValAjax'

// 获取轮播图
export const getSwiper = () => ValAjax.get('/home/swiper')

// 获取小组
export const getGroups = id => ValAjax.get('/home/groups', {
  params: {
    area: id
  }
})

// 获取城市列表
export const getCity = () => ValAjax.get('/area/city', { params: { level: 1 } })

// 获取热门城市
export const getHotCity = () => ValAjax.get('/area/hot')

// 小区关键词查询
export const getCommunity = obj => ValAjax.get('/area/community', { params: obj })

// 上传图片
export const uploadImage = images => ValAjax({
  method: 'POST',
  url: '/houses/image',
  headers: {
    'Content-Type': 'multipart/form-data'
  },
  data: {
    file: images
  }

})

// 提交信息
export const postHouse = obj => ValAjax.post('/user/houses', obj)
// export const postHouse = obj => console.log(obj)

// 获取选择信息
export const getSearchPos = id => ValAjax.get('/houses/condition', {
  params: {
    id
  }
})

// 请求搜索结果
export const getHouse = data => ValAjax.get('/houses', {
  params: {
    ...data
  }
})

// 获取房屋详情
export const getDetial = id => ValAjax.get('/houses/' + id)

// 获取收藏
export const getStar = id => ValAjax.get(`/user/favorites/${id}`)

// 添加收藏
export const opstStar = id => ValAjax.post(`/user/favorites/${id}`, { id })

// 删除收藏
export const delStar = id => ValAjax.delete(`/user/favorites/${id}`, {
  data: {
    id
  }
})

// 获取地图
export const getMap = id => ValAjax.get('/area/map', {
  params: {
    id
  }
})
